package com.gdth.bank.widget;

import java.util.List;

import com.gdth.bank.R;
import com.gdth.model.Item;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

/**
 * 
 * @author lenovo
 *
 */
public class BankDrawDownListAdapter extends BaseAdapter {  
	
	private final int layout_id = R.layout.widget_drawdownlist_textview_item;
    private LayoutInflater layoutInflater;  
    private Context context;  
    
 	/**
 	 * show  
 	 */
 	public boolean isShow = false;  
 	
 	private List<Item> valList;
 	
 	private OnClickListener touchListener;

    public BankDrawDownListAdapter() {  

    }  

    public BankDrawDownListAdapter(Context context, List<Item> valList, OnClickListener touchListener) {  
        this.context = context;  
        this.valList = valList;
        this.touchListener = touchListener;
    }  

    @Override 
    public int getCount() {  
        return valList.size();  
    }  

    @Override 
    public Object getItem(int position) {  
        return null;  
    }  

    @Override 
    public long getItemId(int position) {  
        return position;  
    }  

    @Override 
    public View getView(final int position, View convertView, ViewGroup parent) {  
        Holder holder = null;  
        Item item = valList.get(position);  
        if (convertView == null) {  
            layoutInflater = LayoutInflater.from(context);  
            convertView = layoutInflater.inflate(layout_id, null);  
            holder = new Holder();  
            holder.tv = (TextView) convertView.findViewById(R.id.tv_account);   
            convertView.setTag(holder);  

            holder.tv.setOnClickListener(this.touchListener);
        } else {  
            holder = (Holder) convertView.getTag();  
        }  
        if (holder != null) {  
            convertView.setId(position);  
            holder.setId(position);  
            holder.tv.setText(item.getValue());  
            holder.tv.setTag(item.getKey());  
        }  
        return convertView;  
    }  
    
    public class Holder {  
    	public TextView tv;   
    	
    	void setId(int position) {  
    		tv.setId(position);    
    	}  
    }  
}
